package com.hnust.controller;

import com.hnust.domain.QuestionAnswers;
import com.hnust.service.GetAnswerService;
import com.hnust.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 根据paperId，questionId获取试卷指定题型的题目信息，考生答案，标准答案和解析
 */
@CrossOrigin("*")
@RestController
@RequestMapping("/check")
public class GetAnswerController {
    @Autowired
    private GetAnswerService getAnswerService;
    @GetMapping("/getAnswer")
    public Result<Object> getAnswer(  @RequestParam(value = "testId", required = false) String testId,
                                      @RequestParam(value = "questionId", required = false) String questionId,
                                      @RequestParam(value = "studentId", required = false) String studentId,
                                      @RequestParam(value = "questionType", required = false) String questionType,
                                      @RequestParam(value = "number", required = false) String number) {

        QuestionAnswers questionAnswers = getAnswerService.getAnswer(testId,questionId,studentId,questionType,number);
        if(questionAnswers ==null) return  new Result<>(500, "提供参数有误", null);
        else {
            return  new Result<>(200,"成功", questionAnswers);
        }
    }


}
